unit RelatorioChequesEmitidos;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFormRelatorio, DB, DBTables, QRCtrls, QuickRpt, ExtCtrls,
  StdCtrls;

type
  TFRelatorioChequesEmitidos = class(TFormRelatorio)
    QRGroup1: TQRGroup;
    QRDBText1: TQRDBText;
    QRLabel5: TQRLabel;
    QRBand2: TQRBand;
    QRBand3: TQRBand;
    QRBand4: TQRBand;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    QRDBText4: TQRDBText;
    QRLabel6: TQRLabel;
    QRLabel7: TQRLabel;
    QRLabel8: TQRLabel;
    QRLabel9: TQRLabel;
    QRExpr1: TQRExpr;
    QRExpr2: TQRExpr;
    QRExpr3: TQRExpr;
    QRLabel10: TQRLabel;
    QRLabel11: TQRLabel;
    Query1: TQuery;
    QRLabel4: TQRLabel;
    QRLDataCheque: TQRLabel;
    QRDBText5: TQRDBText;
    QRLabel12: TQRLabel;
    QRDBText6: TQRDBText;
    procedure FormCreate(Sender: TObject);
    procedure QRLabel3Print(sender: TObject; var Value: String);
    procedure QRDBText6Print(sender: TObject; var Value: String);
    procedure QRExpr1Print(sender: TObject; var Value: String);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FRelatorioChequesEmitidos: TFRelatorioChequesEmitidos;

implementation

uses UGeral;

{$R *.dfm}

procedure TFRelatorioChequesEmitidos.FormCreate(Sender: TObject);
begin
  inherited;
 QRelatorio.Close;
 QRelatorio.SQL.Clear;
 QRelatorio.SQL.Add('Select Emp_Razao as Razao from empresa ');
 QRelatorio.SQL.Add('Where Emp_Codigo = :Cod ');
 QRelatorio.ParamByName('Cod').AsInteger:=Codigoempresa;
 QRelatorio.Open;
 QRLNomeEmpresa.Caption:=QRelatorio.fieldByname('Razao').AsString;

end;

procedure TFRelatorioChequesEmitidos.QRLabel3Print(sender: TObject;
  var Value: String);
begin
  inherited;
value:='';
end;

procedure TFRelatorioChequesEmitidos.QRDBText6Print(sender: TObject;
  var Value: String);
const
  sql = 'SELECT MOTIVO FROM CANCELAMENTOCHEQUE WHERE CHEQUE = %s';
var
  Qry : TQuery;
begin
  inherited;
  try
    Qry := TQuery.Create(self);
    Qry.DatabaseName := 'base';
    Qry.SQL.Clear;
    Qry.SQL.Add(Format(sql,[QuotedStr(trim(Query1.FieldByName('CHEQUE').asstring))]));
    Qry.Open;

    if not(Qry.IsEmpty) then
      value := Qry.FieldByName('MOTIVO').AsString
    else
      value := '';
    Qry.Close;
  finally
    Qry.Free;
  end;

end;

procedure TFRelatorioChequesEmitidos.QRExpr1Print(sender: TObject;
  var Value: String);
begin
  inherited;
  if Query1.FieldByName('CANCELADO').AsString = 'S' then
    value := FormatFloat('0.00',Query1.FieldByName('VALOR_CANCELADO').AsFloat);
end;

end.
